#pragma region Copyright
/// <copyright>
/// Copyright (c) 2007 Ilia Shramko.
/// Released under the terms of the GNU General Public License.
/// </copyright>
#pragma endregion

#include "stdafx.h"

int ShowUsage();

int _tmain(int argc, wchar_t* argv[])
{
	if(argc == 1)
		return ShowUsage();

	HWND commandWindow = ::FindWindow(NULL, L"OSH_CmdParser");
	if(commandWindow == NULL)
	{
		wprintf(L"Cannot find OSH_CmdParser window.\r\n");
		return 2;
	}

	if(::SendMessage(commandWindow, WM_SETTEXT, NULL, (LPARAM)argv[1]) != TRUE)
	{
		wprintf(L"Cannot send command to OSH_CmdParser window.\r\n");
		return 3;
	}

	return 0;
}

int ShowUsage()
{
	wprintf(L"Sends command to OSH Host application.\r\n\r\n");
	
	wprintf(L"OSHCmd.exe command\r\n\r\n");

	wprintf(L"Commands:\r\n");
	wprintf(L"    Show                - Shows current OSH screen\r\n");
	wprintf(L"    Hide                - Hides OSH\r\n");
	wprintf(L"    screen:ScreenName   - Goes to ScreenName OSH screen and shows OSH\r\n");
	wprintf(L"    char:Character      - Sends Character to OSH Host\r\n");
	wprintf(L"    Left | Right | Up | Down | PageUp | PageDown | Home | End | Enter\r\n");
	wprintf(L"                        - Sends one of the keyboard keys\r\n");
	wprintf(L"\r\n");
	
	wprintf(L"Examples:\r\n");
	wprintf(L"    OSHCmd.exe Show\r\n");
	wprintf(L"    OSHCmd.exe screen:Home\r\n");
	wprintf(L"    OSHCmd.exe \"command with spaces\"\r\n");
	
	return 1;
}
